﻿using CPPEI.Coolzon.Common;
using CPPEI.Coolzon.Service.Contract;
using CPPEI.Coolzon.UI.Data;
using Sunboxsoft.ChanceData.ServiceProxy.MainServiceRef;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.UI.Views.EventProxies
{
    public class RespScriptNetEventEventHandler : BaseResponseHandler<RespScriptNetEventData>
    {
        protected override void OnHandle(RemoteEventProxy remoteEventProxy, Response response,
            RespScriptNetEventData responseData)
        {
            UI.ScenePart scenePart = remoteEventProxy.RenderView.GetCurrentPart() as ScenePart;
            if (scenePart != null && string.Equals(scenePart.Metadata.Name, responseData.Scene))
            {
                CPPEI.Coolzon.UI.Script.ScriptNetEventObject data = new Script.ScriptNetEventObject();
                data.eventName = responseData.EventName;
                data.dataString = responseData.DataString;
                scenePart.RaiseScriptNetEvent(responseData.EventName, responseData.DataString);
                scenePart.RaiseScriptEvent("OnReceiveNetEvent", data);
            }
        }
    }
}
